//
//  BaifangViewController.m
//  meieshidai
//
//  Created by longziyuan on 14-4-16.
//
//

#import "BaifangViewController.h"
#import "GlobalVar.h"
#import "iToast.h"
@interface BaifangViewController ()

@end

@implementation BaifangViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(id)initWithUrl:(NSString *)urlStr
{
    if (self=[super init]) {
        _urlSt=urlStr;
    }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    self.navigationController.navigationBarHidden=NO;
    self.view.backgroundColor=[UIColor whiteColor];
    
    
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.modalPresentationCapturesStatusBarAppearance = NO;
    }
    
    
    
    
    
    self.title=@"";
    self.view.backgroundColor=[UIColor whiteColor];
    self.navigationController.navigationBar.barStyle=UIBarStyleBlackOpaque;
    
    
    webView=[[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)]autorelease];
    
    [webView setFrame:CGRectMake(0, 0, IPHONE_W, IPHONE_H-49-44-20)];
    
    webView.delegate=self;
    webView.scalesPageToFit=YES;
    [self.view addSubview:webView];

    
    
    
    
    
    
    NSURL* url=[NSURL URLWithString:_urlSt];
    [webView loadRequest:[NSURLRequest requestWithURL:url]];
    
    
    
    UIBarButtonItem* backButton=[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
    self.navigationItem.leftBarButtonItem=backButton;
    [backButton release];

}
-(void)backAction
{
    [self.navigationController popViewControllerAnimated:NO];
}
-(void)webViewDidStartLoad:(UIWebView *)webView
{
    //HUD=[[[MBProgressHUD alloc]initWithView:self.view]autorelease];
    // HUD.removeFromSuperViewOnHide=YES;
    // [self.view addSubview:HUD];
    // [HUD setLabelFont:[UIFont systemFontOfSize:12]];
    // [HUD setLabelText:@"正在加载网页数据..."];
    // [HUD show:YES];
}
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    //[HUD hide:YES];
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    iToast* toast=[iToast makeText:@"网络异常"];
    [toast show];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
